Skip to content

Make comparisons to today consider only stats in the same exact time range#6205

Open
zoldar wants to merge 3 commits intomasterfrom
improve-comparison-to-today
Open

Make comparisons to today consider only stats in the same exact time range#6205
zoldar wants to merge 3 commits intomasterfrom
improve-comparison-to-today

Conversation

@zoldar
Copy link
Copy Markdown
Contributor

@zoldar zoldar commented Mar 26, 2026

Changes

This PR changes behavior when determining time range for "today" when enabling comparisons. Before it, the past time range compared against always included a full day (corrected by site's timezone). Now it only includes the exact time range from midnight relative to the current hour.

The new behavior can be tested live on preview app at https://pr-6205.review.plausible.io/

image

Technical stuff follows...

I have modified input date range parsing logic in both new and legacy query builders to always make an exception for "day" period when it matches today corrected for site's timezone. When the condition is met:

  • the last timestamp of the datetime range is set to query.now
  • the comparison time range is computed by shifting exact time range, like it's done for the 24h period instead of generating a time range for the whole day period

Time related logic got refactored very slightly to reduce repetition and allow mixing dates and datetimes when building DateTimeRange.

Tests

  • Automated tests have been added

Changelog

  • Entry has been added to changelog

@zoldar zoldar force-pushed the improve-comparison-to-today branch from 5dc9c34 to 395e17b Compare March 29, 2026 12:11
@zoldar zoldar added the preview label Mar 30, 2026
@github-actions
Copy link
Copy Markdown

Preview environment👷🏼‍♀️🏗️
PR-6205

@zoldar zoldar requested a review from a team March 30, 2026 13:06
@zoldar zoldar marked this pull request as ready for review March 30, 2026 13:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant